package org.subside.util.commonConfig;

import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.subside.util.QuartzConfig.ConsumerExecute;
import org.subside.util.QuartzConfig.PublisherExecute;

import java.util.Scanner;

/**
 * @Author : zhangbo
 * @data : 2024/4/12
 * @description :
 */
@Configuration
public class config {
//    @Bean
    public static String getString (){
        //根据不同的枚举，加载不同的bean，实现不同的定时任务触发器
        Scanner scanner=new Scanner(System.in);
        return scanner.toString();
    }
    public static void select (){
        String s = getString();
        switch (s) {
            case "1":

                break;
            case "2":

                break;
            case "3":

                break;
            case "4":

                break;
            case "5":

                break;

            default:
                System.out.println("11");
        }
    }

    @Bean("1")
    public JobDetail rabbitMqProducerTaskJobDetail() {
        return JobBuilder.newJob(PublisherExecute.class)
                .withIdentity("rabbitMqProducerTaskJobDetail")
                .storeDurably()
                .build();
    }

    @Bean("1")
    public Trigger rabbitMqProducerTaskTrigger() {
        return TriggerBuilder.newTrigger()
                .forJob(rabbitMqProducerTaskJobDetail())
                .withIdentity("rabbitMqProducerTaskTrigger")
                .withSchedule(CronScheduleBuilder.cronSchedule("*/10 * * * * ?"))
                .build();
    }
    @Bean
    public JobDetail rabbitConsumerTaskJobDetail() {
        return JobBuilder.newJob(ConsumerExecute.class)
                .withIdentity("rabbitConsumerTaskJobDetail")
                .storeDurably()
                .build();
    }

    @Bean
    public Trigger rabbitMqConsumerTaskTrigger() {
        return TriggerBuilder.newTrigger()
                .forJob(rabbitMqProducerTaskJobDetail())
                .withIdentity("rabbitMqConsumerTaskTrigger")
                .withSchedule(CronScheduleBuilder.cronSchedule("*/10 * * * * ?"))
                .build();
    }
}
